<template>
  <a-drawer
    :title="title"
    :width="width"
    placement="right"
    :closable="false"
    @close="close"
    :visible="visible">
  
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item label="客户信息" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['customerId']" placeholder="请输入客户信息"></a-input>
        </a-form-item>
        <a-form-item label="对账单ID" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['statementAccountId']" placeholder="请输入对账单ID"></a-input>
        </a-form-item>
        <a-form-item label="对账单详情ID" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['statementAccountDetailsId']" placeholder="请输入对账单详情ID"></a-input>
        </a-form-item>
        <a-form-item label="支付应收款项ID" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['receivablesId']" placeholder="请输入支付应收款项ID"></a-input>
        </a-form-item>
        <a-form-item label="订单支付时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择订单支付时间" v-decorator="['tradeFinishTime']" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="交易状态：0.成功" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="['tradeState']" placeholder="请输入交易状态：0.成功" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="订单类型：0缴费，1预存" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="['orderType']" placeholder="请输入订单类型：0缴费，1预存" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="订单支付方式" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['tradeType']" placeholder="请输入订单支付方式"></a-input>
        </a-form-item>
        <a-form-item label="支付订单号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['transactionId']" placeholder="请输入支付订单号"></a-input>
        </a-form-item>
        <a-form-item label="更新人" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['updateBy']" placeholder="请输入更新人"></a-input>
        </a-form-item>
        <a-form-item label="更新日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择更新日期" v-decorator="['updateTime']" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="创建人" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['createBy']" placeholder="请输入创建人"></a-input>
        </a-form-item>
        <a-form-item label="创建日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择创建日期" v-decorator="['createTime']" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['remark']" placeholder="请输入备注"></a-input>
        </a-form-item>
        <a-form-item label="所属公司ID" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['companyId']" placeholder="请输入所属公司ID"></a-input>
        </a-form-item>
        <a-form-item label="所属部门CODE" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="['sysOrgCode']" placeholder="请输入所属部门CODE"></a-input>
        </a-form-item>
        <a-form-item label="删除状态(0-正常,1-已删除)" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="['delFlag']" placeholder="请输入删除状态(0-正常,1-已删除)" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="版本号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input-number v-decorator="['versionFlag']" placeholder="请输入版本号" style="width: 100%"/>
        </a-form-item>
        
      </a-form>
    </a-spin>
    <a-button type="primary" @click="handleOk">确定</a-button>
    <a-button type="primary" @click="handleCancel">取消</a-button>
  </a-drawer>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'  
  
  export default {
    name: "StatementAccountDetailsOrderModal",
    components: { 
      JDate,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/zcgl/statementAccountDetailsOrder/add",
          edit: "/zcgl/statementAccountDetailsOrder/edit",
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'customerId','statementAccountId','statementAccountDetailsId','receivablesId','tradeFinishTime','tradeState','orderType','tradeType','transactionId','updateBy','updateTime','createBy','createTime','remark','companyId','sysOrgCode','delFlag','versionFlag'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
         
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'customerId','statementAccountId','statementAccountDetailsId','receivablesId','tradeFinishTime','tradeState','orderType','tradeType','transactionId','updateBy','updateTime','createBy','createTime','remark','companyId','sysOrgCode','delFlag','versionFlag'))
      }
      
    }
  }
</script>

<style lang="less" scoped>
/** Button按钮间距 */
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
</style>